#!/bin/bash
#
# author: test
# email: test
# date: 2021/11/26 18:36
# version: v1.0.0
#
# 功能描述:
# 部署本项目到 k8s 集群中

while getopts 'B:' option; do
  case "$option" in
    B) branch="$OPTARG" ;;
    *) echo "param error ..." && exit 1 ;;
  esac
done

workspace=$(pwd)

tag=$(cat "${workspace}"/deploy/tag.txt)

if [ "$branch" == "test" ]; then
  helm upgrade gupao-p7store-ui "${workspace}/deploy/gupao-p7store-ui" -i --atomic -n devops --set image.tag="${tag}"
else
  helm upgrade gupao-p7store-ui "${workspace}/deploy/gupao-p7store-ui" -i --atomic -n devops --set image.tag="${tag}" -f "${workspace}/deploy/gupao-p7store-ui/prod-values.yaml"
fi
